import { resolve } from 'path';
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import vueJsx from '@vitejs/plugin-vue-jsx';
import AutoImport from 'unplugin-auto-import/vite';
import Components from 'unplugin-vue-components/vite';
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers';
// https://vitejs.dev/config/
export default defineConfig({
    resolve: {
        alias: {
            '@': resolve(__dirname, 'src'), // 根路径路径别名
            '@img': resolve(__dirname, 'src/assets/image') // 图片路径别名
        },
        extensions: ['.js', '.json', '.ts', '.tsx'] // 使用路径别名时想要省略的后缀名，可以自己 增减
    },
    plugins: [
        vue(),
        vueJsx(),
        AutoImport({
            resolvers: [ElementPlusResolver()]
        }),
        Components({
            resolvers: [ElementPlusResolver()]
        })
    ],
    css: {
        preprocessorOptions: {
            scss: {
                additionalData: `@use "./src/styles/global.scss" as *;`
            }
        }
    },
    server: {
        host: '0.0.0.0',
        open: true,
        proxy: {
            '/apis': {
                target: 'http://10.3.1.41:9000',
                ws: true,
                changeOrigin: true,
                rewrite: path => path.replace(/^\/apis/, '')
            }
        }
    },
    build: {
        minify: 'terser',
        terserOptions: {
            compress: {
                // 生产环境时移除console.log()
                drop_console: false,
                drop_debugger: true
            }
        }
    }
});
